<?include("/var/www/html/new/d/common/header.html");
include("/var/www/html/new/d/common/left.html");
include("/var/www/html/new/d/common/page.php");
$currentPage=$_REQUEST["currentPage"]?$_REQUEST["currentPage"]:1;
$pageSize=$_REQUEST['pageSize']?$_REQUEST["pageSize"]:10;
$offset=($currentPage-1)*$pageSize;
$where="where  fid=".$_SESSION['sid'];
$btime=$_REQUEST['btime'];
$etime=$_REQUEST['etime'];
if($days=abs($_REQUEST['days'])){
	$btime=time()-3600*24*$days;
	$btime=date("Y-m-d",$btime);
	$etime=date("Y-m-d");
}
if($btime){
	$where.=" and apply_time>='".$btime." 00:00:00'";
}
if($etime){
	$where.=" and apply_time<='".$etime." 23:59:59'";
}
$str="select c.*,d.dname,d.fee_bank,c.fee_bank_once,c.cut_fee_way from pft_wd_cash c left join pft_member d on d.id=c.fid $where order by apply_time desc limit $offset,$pageSize";

$GLOBALS['le']->query($str);
$r=array();
while($row=$GLOBALS['le']->fetch_assoc()){
	$r[]=$row;
}
$wd_statusT=array(0=>"<em class='orange'>处理中</em>",
				  1=>"<em class='green'>已同意</em>",
				  2=>"<em class=''>已成功</em>",
				  3=>"<em class='red'>已取消</em>",
                  4=>"<em class=''>已拒绝</em>");
?>
<script src="js/Calendar.js" type="text/javascript"></script>
<link href="css/page.css" rel="stylesheet" type="text/css" />
<style>
	.orange{color:orange;}
	.green{color:green;}
	.red{color:red;}
	#right .notice{ margin-bottom: 10px; margin-top: 10px; padding: 20px; border:1px solid #ccc}
	#right .notice span{margin-right:20px}
	#right .time{ width:100px; border:1px solid #7F9DB9; height:18px; background:url("images/rili.png") no-repeat right center #FFFFFF;}
	.apply table{ width:100%; margin-bottom:20px;}
	.apply th{ background: none repeat scroll 0 0 #F3FAFF;border-bottom: 1px solid #DDEEFB;border-top: 1px solid #DDEEFB;height: 27px;line-height: 27px;text-align: center;}
	.apply td{ border-bottom: 1px dashed #DDDDDD;line-height: 20px;padding: 10px 0;text-align: center;}
	.butbg{background:url(../images/search.png) no-repeat 0 0; cursor: pointer;height: 30px;width: 80px;border:none;}
</style>
	<!--提现记录-->

    <div id="right" class="r_content"><!--BEGIN OF RIGHT-->
		<h3 class="mc_title">
			<span class="mctit_1"><span class="mctit_2">账户提现</span></span>
		</h3>
		<div class="notice">
			<form action="">
				<span>申请日期：<input type="text" class="time" onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)" value="<?=$btime?>" name="btime" /> 至 <input type="text" class="time" name="etime" onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)" value="<?=$etime?>"/></span><i> </i>
				<span>
					<a href="?days=7" class="monrea <?=($days==7)?"cuream":""?>">最近7天</a>
					<a href="?days=30" class="monrea <?=($days==30)?"cuream":""?>">最近30天</a></span>
				<span><input type="submit" value=" " class="butbg" /></span>
			</form>
		</div>
		
		<div class="apply">
			<table>
				<tr class="header">
					<th class="col5">申请日期</th>
					<th class="col4">提现金额</th>
					<th class="col2">手续费</th>
                    <th class="col8">手续费扣费方式</th>
					<th class="col3">应收金额</th>
					<th class="col1">收款账号</th>
					<th class="col6">操作员</th>
					<th class="col7">状态</th>
					<th>操作</th>
				</tr>
				<?foreach($r as $row){?>
                    <?
                    $a=$row['wd_money']/100/(1+$row['fee_bank_once']/1000);
                    $wm=$row['cut_fee_way']?(($row['wd_money']/100-$a<1)?($row['wd_money']/100-1):$a):($row['wd_money']/100);
                    $pay_money=$wm*$row['fee_bank_once']/1000;
                    $pm=($pay_money<1&&$pay_money>0)? 1:$pay_money;
                    ?>
				<tr class="<?=(++$i%2==0)?"odd":"even"?>">
					<td class="col5">
						<span title="<?=$row['apply_time']?>">
							<?=substr($row['apply_time'],0,10)?>
						</span>
					</td>
                    <td class="col4"><?=sprintf("%.2f",$wm);?></td>
                    <td class="col2"><?=sprintf("%.2f",$pm);?></td>
                    <td class="col8"><?=$row['cut_fee_way']?"账户余额扣除":"提现现金扣除";?></td>
                    <td class="col3"><?=sprintf("%.2f",$row['cut_fee_way']?$wm:($wm-$pm));?></td>
                    <td class="col1"><?=$row['wd_name']?> <?=$row['bank_name']?></br><?=substr_replace($row['bank_accuont'],"***",4,11);?></td>
					<td class="col6"><?=$row['dname']?></td>
					<td class="col7"><?=$wd_statusT[$row['wd_status']]?></td>
					<td><?if($row['wd_status']=='0'){?><a class="cancel" href="call/handle.php?from=withdraw_cancel&id=<?=$row['id']?>">取消申请</a><?}else{?>已处理<?}?></td>
				</tr>
				<?}?>
				<?if(count($r)==0){?>
				<tr><td style="text-align:left; padding-left:50px;" colspan='9'>无处理中提现申请</td></tr>
				<?}?>
			</table>
			<?if(count($r)>0) page(count($r),$currentPage,$pageSize);?>
		</div>
	</div><!--EOF RIGHT--> 
	<!--提现记录END-->
<script>
	$(".cancel").click(function(){
		if(confirm("确定要取消提现申请?")){
			$.ajax({
				"url":$(this).attr("href"),
				"dataType":"json",
				"success":function(data){
					if(data.outcome==1){
						alert("取消成功");
						window.location=window.location.href;
					}else{
						alert("取消失败");
					}
				}
			})
		}
		return false;
	})
</script>
<?include("/var/www/html/new/d/common/footer.html");?>